package com.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.entity.SmsHotCommodity;
import com.mall.mapper.SmsHotCommodityMapper;
import com.mall.service.SmsHotCommodityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SmsHotCommodityServiceImpl extends ServiceImpl<SmsHotCommodityMapper, SmsHotCommodity> implements SmsHotCommodityService {

    @Resource
    private SmsHotCommodityMapper smsHotCommodityMapper;

    @Override
    public SmsHotCommodity getById(Integer id) {
        return smsHotCommodityMapper.selectById(id);
    }

    @Override
    public List<SmsHotCommodity> getAll() {
        return smsHotCommodityMapper.selectList(null);
    }

    @Override
    public boolean deleteById(Integer id) {
        return smsHotCommodityMapper.deleteById(id) > 0;
    }

    @Override
    public boolean save(SmsHotCommodity smsHotCommodity) {
        if(smsHotCommodity.getId() == null)
        {
            return smsHotCommodityMapper.insert(smsHotCommodity) > 0;
        }else{
            return  smsHotCommodityMapper.updateById(smsHotCommodity) > 0;
        }
    }
}
